<?php
class XA_XHTML_Page extends XA_XHTML {

	public $title = SITE_NAME;
	public $generator = 'Xantipe';
	public $stylesheet_list = array();
	public $script_list = array();
	public $head_script_includes = array();
	public $encoding = 'UTF-8';
	public $layout = 'default';
	public $template = 'default';
	public $content = array();
	public $html_version = 'x10';



	public function out() {
		global $user, $action;
		$template_path = MODULE_PATH.'templates/'.$this->template.'.php';
		$c =& $this->content;
		extract($this->content, EXTR_REFS | EXTR_SKIP);

		$tag_list = array();

		foreach ($this->stylesheet_list as $sheet) {
			$tag_list[] = '<link rel="stylesheet" href="'.$sheet.'" type="text/css" />';
		}

		foreach ($this->script_list as $script) {
			$tag_list[] = '<script type="text/javascript" src="'.$script.'"></script>';
		}


		switch ($this->html_version) {
			case '5': {
				echo '<!DOCTYPE html>
<html>
	<head>
		<meta name="generator" content="'.$this->generator.'" />
		<meta http-equiv="Content-Type" content="text/html; charset='.$this->encoding.'" />
';
				break;
			}

			default: {
				echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="generator" content="'.$this->generator.'" />
		<meta http-equiv="Content-Type" content="text/html; charset='.$this->encoding.'" />
';
			}
		}

		echo '
		<title>'.$this->title.'</title>
		'.implode("\n\t\t", $tag_list).'
		<link rel="shortcut icon" type="image/x-icon" href="'.SITE_URL.'favicon.ico" />
		';

		foreach ($this->head_script_includes as $script) {
			echo "
		<script type=\"text/javascript\">\n";

			include(APP_PATH.$script);

			echo "
		</script>\n";
		}

		echo '
	</head>
	<body class="'.implode(' ', $this->class_list).'">
';

		require(MODULE_PATH.'templates/layouts/'.$this->layout.'.php');

		echo '
	</body>
</html>
';
	}

}
